<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form id="frmCustomer">
		<input type="hidden" name="customer.id" value="${customer.id}" /> <input type="hidden" name="customer.personal.id"
			value="${customer.personal.id}" />
		<s:set id="sexes" value="#{'Man':'男','Woman':'女'}" />
		<s:set id="receiveOptions" value="#{'true':'是','false':'否'}" />
		<div class="easyui-tabs" data-options="border:true,tabPosition:'top'" style="width: fill; height: 430px">
			<div title="基本信息">
				<table width="100%">
					<tr>
						<td width="65" align="right"><span>客户编码：</span></td>
						<td width="162" align="left"><input class="easyui-validatebox" type="text" name="customer.code"
							data-options="required:true" value="${customer.code}" style="width: 98%" /></td>
						<td align="right"><span>注册日期：</span></td>
						<td width="162" align="left"><input type="text" name="customer.createDate" value="${customer.createDate}"
							disabled="disabled" style="width: 98%" /></td>
					</tr>
					<tr>
						<td><span>客户姓名：</span></td>
						<td><input class="easyui-validatebox" type="text" name="customer.name" data-options="required:true"
							value="${customer.name}" style="width: 98%" /></td>
						<td><span>性别：</span></td>
						<td><s:radio list="sexes" name="customer.personal.sex" value="customer.personal.sex" theme="simple" /></td>
					</tr>
					
					<tr>
						<td><span>出生日期：</span></td>
						<td><input type="text" width="98%" class="easyui-datebox" name="customer.personal.birthday"
							data-options="formatter:myformatter,parser:myparser,currentText:'今天',closeText:'关闭'"
							value="${customer.personal.birthday}" /></td>
						<td><span>是否接受会刊：</span></td>
						<td><s:radio list="receiveOptions" name="customer.receiveDoc" value="customer.receiveDoc" theme="simple" /></td>
					</tr>
					<tr>
						<td><span>联系电话1：</span></td>
						<td><input class="easyui-validatebox" type="text" name="customer.personal.phone1" data-options="required:true"
							value="${customer.personal.phone1}" style="width: 98%" /></td>
						<td><span>联系电话2：</span></td>
						<td><input type="text" name="customer.personal.phone2" value="${customer.personal.phone2}" style="width: 98%" /></td>
					</tr>
					<tr>
						<td><span>证件类型：</span></td>
						<td><s:select list="cardCategories" listKey="id" listValue="name" name="customer.personal.cardCategoryId"
								value="customer.personal.cardCategoryId" theme="simple" cssStyle="width: 98%" emptyOption="true" /></td>
						<td><span>证件号码：</span></td>
						<td><input class="easyui-validatebox" type="text" name="customer.personal.cardNumber" data-options="required:true"
							value="${customer.personal.cardNumber}" style="width: 98%" /></td>
					</tr>
					<tr>
						<td><span>客户类型：</span></td>
						<td><s:select list="types" listKey="id" listValue="name" name="customer.typeId" value="customer.typeId"
								theme="simple" cssStyle="width: 98%" emptyOption="true" cssClass="easyui-combobox"  /></td>
						<td><span>客户级别：</span></td>
						<td><s:select list="levels" listKey="id" listValue="name" name="customer.levelId" value="customer.levelId"
								theme="simple" cssStyle="width: 98%" emptyOption="true" /></td>
					</tr>
					<tr>
						<td><span>从事职业：</span></td>
						<td><s:select list="professions" listKey="id" listValue="name" name="customer.professionId"
								value="customer.professionId" theme="simple" cssStyle="width: 98%" emptyOption="true" /></td>
						<td><span>月收入：</span></td>
						<td><s:select list="incomes" listKey="id" listValue="name" name="customer.incomeId" value="customer.incomeId"
								theme="simple" cssStyle="width: 98%" emptyOption="true" /></td>
					</tr>
					<tr height="45">
						<td><span>描述：</span></td>
						<td colspan="3"><textarea rows="3" name="customer.description" style="width: 98%">${customer.description}</textarea></td>
					</tr>
				</table>
			</div>
			<div title="其他信息">
				<table width="100%">
					<tr>
						<td width="80"><span>工作单位：</span></td>
						<td align="left"><input type="text" name="customer.personal.workUnit" value="${customer.personal.workUnit}"
							style="width: 98%" /></td>
					</tr>
					<tr>
						<td><span>联系地址：</span></td>
						<td><input type="text" name="customer.personal.address" value="${customer.personal.address}" style="width: 98%" /></td>
					</tr>
					<tr>
						<td><span>个人爱好：</span></td>
						<td><s:checkboxlist list="hobbies" listKey="id" listValue="name" name="customer.hobbies" value="customer.hobbies"
								theme="simple"></s:checkboxlist></td>
					</tr>
				</table>
			</div>
		</div>
	</form>

	<div style="text-align: center; padding: 5px">
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitFrmCustomer()">保存</a> <a href="javascript:void(0)"
			class="easyui-linkbutton" onclick="closewinCustomer()">关闭</a>
	</div>

	<script type="text/javascript">
		function submitFrmCustomer() {
			var issubmit = true;
			$("input.easyui-validatebox").each(function(obj) {
				if ($(this).validatebox("isValid") == false) {
					issubmit = false;
				}
			});
			if (issubmit) {
				var params = $("#frmCustomer").serialize();
				$.ajax({
					url : "${path}/business/customer/save.do",
					type : "POST",
					data : params,
					dataType : "json",
					success : function(data) {
						if (null != data.message) {
							$.messager.alert("提示信息", data.message);
						} else {
							$.messager.alert("提示信息", "数据保存成功！");
						}
					}
				});
			}
		}
	</script>
</body>
</html>